<@app.html>
    <@app.head>
    <script>
        $(function () {
            $('#page_table').datagrid({
                fit: true,
                width: '100%',
                height: '100%',
                striped: true,
                pagination: true,
                url: "${contextPath}/security/hdw/rescuer/page.htm",
                fitColumns: true,
                pageSize: 10,
                pageList: [10, 50, 100],
                idField: 'id',
                singleSelect: true,
                selectOnCheck: false,
                checkOnSelect: false,
                autoRowHeight: false,
                rowStyler: gridRowStyler,
                columns: [
                    [

                        {title: '救援人员', align: 'center', field: 'rescuerName', width: 80},
                        {title: '联系电话', align: 'center', field: 'tel', width: 80},
                        {
                            title: '地址',
                            align: 'center',
                            field: 'address',
                            width: 80,
                            formatter: function (val, row) {
                                return (row.provinceName || '') + (row.cityName || '') + (row.districtName || '') + (row.street || '');
                            }
                        },
                        {title: '服务内容', align: 'center', field: 'serviceContent', width: 80},
                        {title: '价格（元）', align: 'center', field: 'price', width: 60},

                        {
                            title: '星标', align: 'center', field: 'star', width: 60,
                            formatter: function (val) {
                                <#list starEnum as e>
                                    if (${e.getValue()} == val
                                    )
                                    return '${e.getName()}';
                                </#list>
                            }
                        },

                        {
                            title: '操作',
                            align: 'center',
                            field: 'action',
                            width: 100,
                            formatter: function (val, row) {
                                var html = '<a href="javascript:view(ID)">查看</a>';
                                <@app.has_oper oper_code='1_7_3'>
                                    html += ' <a href="javascript:edit(ID)">修改</a>';
                                </@app.has_oper>
                                <@app.has_oper oper_code='1_7_4'>
                                    html += ' <a href="javascript:remove(ID)">删除</a>';
                                </@app.has_oper>
                                return html.replace(/ID/g, row.id);
                            }
                        }
                    ]
                ],
                queryParams: {
                parentId: <#if Session['SESSION_KEY_USER'].agentId != 0>${Session['SESSION_KEY_USER'].agentId}<#else>''</#if>
                },
                onLoadSuccess: function () {
                    $('#page_table').datagrid('clearChecked');
                    $('#page_table').datagrid('clearSelections');
                }
            });
        });


        function reload() {
            var datagrid = $('#page_table');
            datagrid.datagrid('reload');
        }

        function query() {
            var datagrid = $('#page_table');
            var serviceContent = $('#service_content').val();
            var agentId = $('input[name="agentId"]').val();
//            var provinceId = $('#province_id_').val();
//            var cityId = $('#city_id_').val();
//            var districtId = $('#district_id_').val();
            datagrid.datagrid('options').queryParams = {
//                provinceId: provinceId,
//                cityId: cityId,
//                districtId: districtId,
                serviceContent: serviceContent,
                agentId: agentId
            };
            datagrid.datagrid('load');
        }

        function add() {
            App.dialog.show({
                css: 'width:786px;height:530px;overflow:visible;',
                title: '新建',
                href: "${contextPath}/security/hdw/rescuer/add.htm",
                event: {
                    onClose: function () {
                        reload();
                    }
                }
            });
        }
        function edit(id) {
            App.dialog.show({
                css: 'width:786px;height:480px;overflow:visible;',
                title: '修改',
                href: "${contextPath}/security/hdw/rescuer/edit.htm?id=" + id,
                event: {
                    onClose: function () {
                        reload();
                    },
                    onLoad: function () {
                    }
                }
            });
        }
        function view(id) {
            App.dialog.show({
                css: 'width:786px;height:512px;overflow:visible;',
                title: '查看',
                href: "${contextPath}/security/hdw/rescuer/view.htm?id=" + id
            });
        }

        function remove(id) {
            $.messager.confirm('提示信息', '确认删除?', function (ok) {
                if (ok) {
                    $.post('${contextPath}/security/hdw/rescuer/delete.htm', {
                        id: id
                    }, function (json) {
                        if (json.success) {
                            $.messager.alert('提示消息', '操作成功', 'info');
                            reload();
                        } else {
                            $.messager.alert('提示消息', json.message, 'info');
                        }
                    }, 'json');
                }
            });
        }

    </script>
    </@app.head>
    <@app.body>
        <@app.container>
            <@app.banner/>

        <div class="main">
            <@app.menu/>

            <div class="content">
                <div class="panel search">
                    <div class="float_right">
                        <button class="btn btn_yellow" onclick="query()">搜索</button>
                    </div>
                    <table cellpadding="0" cellspacing="0" border="0">
                        <tr>
                            <#if Session['SESSION_KEY_USER'].type == Session['USER_TYPE_PLATFORM'].value>
                                <td align="right">运营商：</td>
                                <td>
                                    <input name="agentId" class="easyui-combotree" editable="false"
                                           style="width: 184px; height: 28px;"
                                           data-options="url:'${contextPath}/security/basic/agent/tree.htm?dummy=${'所有'?url}',method:'get'"/>
                                </td></#if>
                            <td align="right">服务内容：</td>
                            <td><input type="text" class="text" id="service_content"/></td>
                        </tr>
                    </table>
                </div>
                <div class="panel grid_wrap">
                    <div class="toolbar clearfix">
                        <div class="float_right">
                            <@app.has_oper oper_code='1_7_2'>
                                <button class="btn btn_green" onclick="add()">新建</button>
                            </@app.has_oper>
                        </div>
                        <h3>移动救援</h3>
                    </div>
                    <div class="grid">
                        <table id="page_table"></table>
                    </div>
                </div>
            </div>
        </div>
        </@app.container>
    </@app.body>
</@app.html>


